﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace FamilyTree
{
    public partial class TreeDel : Form
    {
        public TreeDel()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void label3_Click(object sender, EventArgs e)
        {
            string connString = @"Data Source = PC-20190806MQPW\SQLEXPRESS01; Initial Catalog = 终极电子族谱; User ID = sa; Password = 123456"; //数据库连接
            string id = textBox1.Text;
            string maker = textBox2.Text;
            SqlConnection conn = new SqlConnection(connString);
            conn.Open();
            string sql = @"DELETE FROM tree WHERE id='" + id + "' AND maker='"+maker+"'";
            SqlCommand cmd = new SqlCommand(sql, conn);
            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show(id + "族谱删除成功！");
            }
            catch (Exception ex)
            {
                MessageBox.Show("删除出错！" + ex.Message);
            }
            conn.Close();
        }
    }
}
